﻿using System;
using System.Collections.Generic;
using System.Text;

namespace GolfSigma.Inventory
{
    /// <summary>
    /// Configuration for accessing the GolfSigma Inventory API
    /// </summary>
    public class InventoryConfig
    {
        private string serviceURL = "http://inv.golfsigmaws.com";
        private string userAgent = "GolfSigma Inventory CSharp Library";
        private string signatureVersion = "1";
        private string signatureMethod = "HmacSHA256";
        private string proxyHost = null;
        private int proxyPort = -1;
        private int maxErrorRetry = 3;
        private int requestTimeout = 30;
        private bool setForwardedFor = false;
        private bool disableCompression = false;
        private bool isMono = false;

        public InventoryConfig()
        {
            // Determine if we are running in mono
            try
            {
                this.isMono = Type.GetType("Mono.Runtime") != null;
            }
            catch { }
        }

        /// <summary>
        /// Gets the signatureMethod property.
        /// </summary>
        public string SignatureMethod
        {
            get { return this.signatureMethod; }
        }

        /// <summary>
        /// Gets the SignatureVersion property.
        /// </summary>
        public string SignatureVersion
        {
            get { return this.signatureVersion; }
        }

        /// <summary>
        /// Gets and sets of the UserAgent property.
        /// </summary>
        public string UserAgent
        {
            get { return this.userAgent; }
            set { this.userAgent = value; }
        }

        /// <summary>
        /// Gets and sets of the ServiceURL property.
        /// </summary>
        public string ServiceURL
        {
            get { return this.serviceURL; }
            set { this.serviceURL = value; }
        }

        /// <summary>
        /// Gets and sets of the ProxyHost property.
        /// </summary>
        public string ProxyHost
        {
            get { return this.proxyHost; }
            set { this.proxyHost = value; }
        }

        /// <summary>
        /// Checks if ProxyHost property is set
        /// </summary>
        /// <returns>true if ProxyHost property is set</returns>
        public bool IsSetProxyHost()
        {
            return this.proxyHost != null;
        }

        /// <summary>
        /// Gets and sets of the ProxyPort property.
        /// </summary>
        public int ProxyPort
        {
            get { return this.proxyPort; }
            set { this.proxyPort = value; }
        }

        /// <summary>
        /// Checks if ProxyPort property is set
        /// </summary>
        /// <returns>true if ProxyPort property is set</returns>
        public bool IsSetProxyPort()
        {
            return this.proxyPort != -1;
        }

        /// <summary>
        /// Gets and sets of the MaxErrorRetry property.
        /// </summary>
        public int MaxErrorRetry
        {
            get { return this.maxErrorRetry; }
            set { this.maxErrorRetry = value; }
        }

        /// <summary>
        /// Checks if MaxErrorRetry property is set
        /// </summary>
        /// <returns>true if MaxErrorRetry property is set</returns>
        public bool IsSetMaxErrorRetry()
        {
            return this.maxErrorRetry != -1;
        }

        /// <summary>
        /// Gets and sets of the SetForwardedFor Property
        /// </summary>
        public bool SetForwardedFor
        {
            get { return this.setForwardedFor; }
            set { this.setForwardedFor = value; }
        }

        /// <summary>
        /// Request timeout. Defaults to 30 (seconds)
        /// </summary>
        public int RequestTimeout
        {
            get { return this.requestTimeout; }
            set { this.requestTimeout = value; }
        }

        /// <summary>
        /// Disable the Accept-Encoding: gzip, deflate
        /// </summary>
        public bool DisableCompression
        {
            get { return this.disableCompression; }
            set { this.disableCompression = value; }
        }

        public bool IsMono
        {
            get { return this.isMono; }
        }
    }
}
